#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
const char * path = "fifo";
int main()
{
    if(access(path, F_OK) < 0)
    {
        mkfifo(path, 0666);
    }
    int fd = open(path, O_WRONLY);
    char buffer[1024] = {};
    sprintf(buffer, "I am a child process, pid : %d\n", getpid());
    int n = 8;
    while(n--)
    {
        int n = write(fd, buffer, sizeof(buffer));
        if(n < 0)
        {
            perror("write");
            break;
        }
        sleep(1);
    }
    printf("写进程退出\n");
    return 0;
}